package com.yimi.yinhepda.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.yimi.yinhepda.R;
import com.yimi.yinhepda.entity.bean.BackReasonEntity;

import java.util.List;

/**
 * 配送退单原因适配器
 *
 * @author 000432
 * @date 2018/3/8 0008
 */
public class DispatchBackReasonAdapter extends BaseAdapter {

  private List<BackReasonEntity> mList;
  private Context mContext;

  public DispatchBackReasonAdapter(Context context, List<BackReasonEntity> list) {
    this.mContext = context;
    this.mList = list;
  }

  @Override public int getCount() {
    return mList.size();
  }

  @Override public Object getItem(int position) {
    return mList.get(position);
  }

  @Override public long getItemId(int position) {
    return position;
  }

  @Override public View getView(final int position, View convertView, ViewGroup parent) {
    ViewHolder holder;
    if (convertView == null) {
      holder = new ViewHolder();
      convertView = LayoutInflater.from(mContext).inflate(R.layout.dispatch_back_reason_item, null);
      holder.mBackReason = (TextView) convertView.findViewById(R.id.back_reason_item);
      convertView.setTag(holder);
    } else {
      holder = (ViewHolder) convertView.getTag();
    }

    BackReasonEntity entity = mList.get(position);
    holder.mBackReason.setText(entity.getBackReason());
    return convertView;
  }

  static class ViewHolder {
    TextView mBackReason;
  }
}
